//ajax请求,callback为回调函数	
	var sendAjaxRequest = function(url,json,otherData,callback){
		$.ajax({
			type : "GET",
			url : url,
			cache : false,
			data : json,
			//dataType : "text",
			dataType : "TEXT",
			async : false,
			error:function(XMLResponse){alert(XMLResponse.responseText)},
			success : function(data) {
				if (callback) {
					callback({
						data : data
					});
				}
			}
		});
	}
	
	var JSHttpRequest=function(url, data,success){
		
		var xmlhttp = new XMLHttpRequest();
		//xmlhttp.upload.onprogress = uploadProgress;
		
		xmlhttp.onreadystatechange = function () {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				var data = xmlhttp.responseText;
				success(data);


			}
			if (xmlhttp.status == 200) {
				var data = xmlhttp.responseText;
				success(data);


			}
			if (xmlhttp.readyState == 4 && xmlhttp.status == 404) {
				alert('404错误');
				
			}
		}
		xmlhttp.open("POST", url, true);
		xmlhttp.send(data);

	}
	
	//调用ajax函数
var SendAjax = function (url, data, asy, success,
    error,//errormsg,errorfunction
    timeout)//timeoutmsg,timeoutset,timeoutfunction
{
    if (asy == undefined || asy == null)
        asy = true; //默认使用异步
    if (timeout == undefined || timeout.timeoutset == null || timeout.timeoutset < 1000) {
        timeout = {
            timeoutset: -1,
        }
        
    };
    if (error.errorfunction == undefined || error.errorfunction == null) {
        error = {
            errorfunction: new function () { },
        }

    };
    if (timeout.timeoutfunction == undefined || timeout.timeoutfunction == null) {
        timeout = {
            timeoutfunction: new function () { },
        }

    };
    if (success == undefined || success == null) {
        success = new function () { };
    };
    $.ajax({
        type: "GET",//GET POST
        //contentType: "application/json;charset=UTF-8",
        contentType: "application/json",	
		//contentType: "text",
        timeout: timeout.timeoutset,
        url: url,
		data:"{}",
        //data: data,
        async: asy,
        //traditional: true,
        //dataType: "application/json",
        //dataType: "json",
		dataType: "jsonp",//text
		jsonpCallback:"jsonpCallback",
        success: success,
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            if (errorThrown == 'timeout') {
                //SendAjax.abort();
                timeout.timeoutfunction;
                if (timeout.timeoutmsg != undefined && timeout.timeoutmsg != null && timeout.timeoutmsg != '')
                    alert(timeout.timeoutmsg);
            }
            else {
                error.errorfunction;
                if (error.errormsg != undefined && error.errormsg != null && error.errormsg != '')
                    alert(error.errormsg);
            }

        },
        complete: function (XMLHttpRequest, status) { //请求完成后最终执行参数
            //status有success,error,timeout等值的情况
        },
    });
}
	
	var sendAjaxRequestWithMultiType = function(url,json,otherData,callback){
		$.ajax({
			type : "POST",
			url : url,
			cache : false,
			data : json,
			contentType:'application/json;charset=utf-8',
			dataType : "json",
			async : false,
			error:function(XMLResponse){alert(XMLResponse.responseText)},
			success : function(data) {
				if (callback) {
					callback({
						data : data
					});
				}
			}
		});
	}
	
//序列化表单数据,验证并提交
	function submitFormAndValidate(formID,targetUrl,callback){
		$("#"+formID).form('submit',{ 
	        url: targetUrl, 
	        onSubmit: function () {        //表单提交前的回调函数 
	          var isValid = $(this).form('validate');//验证表单中的一些控件的值是否填写正确，比如某些文本框中的内容必须是数字 
	          if (!isValid) { 
	          } 
	          return isValid; // 如果验证不通过，返回false终止表单提交 
	        }, 
	        success: function (data) {  //表单提交成功后的回调函数
	        	var jsonObj = eval("("+data+")");
	        	if ("success" == jsonObj.type) {
	            $.messager.show({ 
	              title: '提示消息', 
	              msg: jsonObj.message, 
	              showType: 'show', 
	              timeout: 1000, 
	              style: { 
	                right: '', 
	                bottom: '' 
	              } 
	            }); 
				if (callback) //回调函数,外部操作可以写在这里
				{
					callback
					({
						data : data
					});
				}
	          }else if("warning"== jsonObj.type){
	        	  $.messager.alert('提示信息', jsonObj.message, 'warning'); 
	          } 
	          else { 
	            $.messager.alert('提示信息', jsonObj.message, 'error'); 
	        } 
	        } 
		}    
		)
	}
	
	//精确相加
	function add(a, b) {
	    var c, d, e;
	    try {
	        c = a.toString().split(".")[1].length;
	    } catch (f) {
	        c = 0;
	    }
	    try {
	        d = b.toString().split(".")[1].length;
	    } catch (f) {
	        d = 0;
	    }
	    return e = Math.pow(10, Math.max(c, d)), (mul(a, e) + mul(b, e)) / e;
	}
	
	//精确相减
	function sub(a, b) {
	    var c, d, e;
	    try {
	        c = a.toString().split(".")[1].length;
	    } catch (f) {
	        c = 0;
	    }
	    try {
	        d = b.toString().split(".")[1].length;
	    } catch (f) {
	        d = 0;
	    }
	    return e = Math.pow(10, Math.max(c, d)), (mul(a, e) - mul(b, e)) / e;
	}
	
	//精确相乘
	function mul(a, b) {
	    var c = 0,
	        d = a.toString(),
	        e = b.toString();
	    try {
	        c += d.split(".")[1].length;
	    } catch (f) {}
	    try {
	        c += e.split(".")[1].length;
	    } catch (f) {}
	    return Number(d.replace(".", "")) * Number(e.replace(".", "")) / Math.pow(10, c);
	}
	
	//精确相除
	function div(a, b) {
	    var c, d, e = 0,
	        f = 0;
	    try {
	        e = a.toString().split(".")[1].length;
	    } catch (g) {}
	    try {
	        f = b.toString().split(".")[1].length;
	    } catch (g) {}
	    return c = Number(a.toString().replace(".", "")), d = Number(b.toString().replace(".", "")), mul(c / d, Math.pow(10, f - e));
	}
	
	//强制保留2位小数，如：2，会在2后面补上00.即2.00  
	function toDecimal2(x) {      
	        var f = parseFloat(x);   //将字符串转换为浮点型      
	        if (isNaN(f)) {       //isNaN() 函数用于检查其参数是否是非数字值。  
	            return false;      
	        }      
	        var f = Math.round(x*100)/100;      
	        var s = f.toString();      
	        var rs = s.indexOf('.');      
	        if (rs < 0) {      
	            rs = s.length;      
	            s += '.';      
	        }      
	        while (s.length <= rs + 2) {      
	            s += '0';      
	        }      
	        return s;      
	    }  

          function fillEasyuiComboBox(url,domID)
         {
             console.log('do fill>>>');
            sendAjaxRequest(url, null,domID, function(data){
                    var jsonObj = data.data;
                    if("success" ==  jsonObj.type){
                            $.each(jsonObj.data,function(i,obj)
                                    {
                                            $("#"+domID).append("<option value='"+obj+"'>"+obj+"</option>");
                                    })
                    }
                    $("#"+domID).combobox();
            });
         }